/*
 * @Author: y001554
 * @Date: 2023-01-16 20:11:08
 * @LastEditors: y001554
 * @LastEditTime: 2023-02-16 10:06:04
 * @FilePath: \ylwl\packages\plugins\components\table\src\composables\use-select.tsx
 * @Description:
 *
 * Copyright (c) 2023 by FE/ylwl, A l Rights Reserved
 */
import { ref, reactive, onMounted } from 'vue'
import { ItemData } from '../type'

export default function useSelect(context: any, domRef: any): any {
  const { slots, emit, attrs, expose } = context

  const all = ref<ItemData>([])

  const selectFn = (e: ItemData): void => {
    // debugger
    all.value = e
    emit('update:modelValue', e)
  }
  const clearFn = () => {
    if (domRef.value) {
      domRef.value.clearSelection()
    }
  }

  const allFn = () => {
    if (domRef.value) {
      domRef.value.toggleAllSelection()
    }
  }

  onMounted(async () => {
    // alert(0)
  })
  return {
    all,
    selectFn,
    clearFn,
    allFn
  }
}
